home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBToolbar / ToolBarDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  10.1 KB  |  333 lines

  1. // ToolBarDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "HTBToolbar.h"
  6. #include "ToolBarDlg.h"
  7. #include "export.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // ToolBarDlg dialog
  17.  
  18.  
  19. ToolBarDlg::ToolBarDlg(CWnd* pParent /*=NULL*/)
  20.     : CDialog(ToolBarDlg::IDD, pParent)
  21. {
  22.     //{{AFX_DATA_INIT(ToolBarDlg)
  23.         // NOTE: the ClassWizard will add member initialization here
  24.     //}}AFX_DATA_INIT
  25. }
  26.  
  27.  
  28. void ToolBarDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(ToolBarDlg)
  32.         // NOTE: the ClassWizard will add DDX and DDV calls here
  33.     //}}AFX_DATA_MAP
  34. }
  35.  
  36.  
  37. BEGIN_MESSAGE_MAP(ToolBarDlg, CDialog)
  38.     //{{AFX_MSG_MAP(ToolBarDlg)
  39.     ON_COMMAND(ID_PRINTER, OnDumpit)
  40.     ON_COMMAND(ID_SAVE, OnSavefile)
  41.     ON_COMMAND(ID_ERASE, OnErase)
  42.     ON_COMMAND(ID_NEW, OnNewpad)
  43.     ON_COMMAND(ID_RED, OnRed)
  44.     ON_COMMAND(ID_BLUE, OnBlue)
  45.     ON_COMMAND(ID_YELLOW, OnYellow)
  46.     ON_COMMAND(ID_PURPLE, OnPurple)
  47.     ON_COMMAND(ID_WHITE, OnWhite)
  48.     //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // ToolBarDlg message handlers
  53.  
  54. BOOL ToolBarDlg::OnInitDialog() 
  55. {
  56.     CDialog::OnInitDialog();
  57.     
  58.     // Create the Toolbar
  59.     CreateToolBar();
  60.     
  61.     return TRUE;  // return TRUE unless you set the focus to a control
  62.                   // EXCEPTION: OCX Property Pages should return FALSE
  63. }
  64.  
  65. /*************************************************************************
  66. **************************************************************************
  67. **                                                                        **
  68. **            Name:         SetupImages                                    **
  69. **                                                                        **
  70. **            Parameters:  CImageList*                                    **
  71. **                                                                        **
  72. **            Description: Adds the Button Icons to the CImageList        **
  73. **                                                                        **
  74. **                                                                        **
  75. **************************************************************************
  76. **************************************************************************/
  77. BOOL ToolBarDlg::SetupImages(CImageList* mImageList)
  78. {
  79.     CWinApp* pApp = AfxGetApp();
  80.     mImageList->Create(24, 24, ILC_COLOR8 | ILC_MASK,  9, 9);
  81.     mImageList->Add(pApp->LoadIcon(IDI_ICON1));
  82.     mImageList->Add(pApp->LoadIcon(IDI_ICON2));
  83.     mImageList->Add(pApp->LoadIcon(IDI_ICON3));
  84.     mImageList->Add(pApp->LoadIcon(IDI_ICON4));
  85.     mImageList->Add(pApp->LoadIcon(IDI_ICON5));
  86.     mImageList->Add(pApp->LoadIcon(IDI_ICON6));
  87.     mImageList->Add(pApp->LoadIcon(IDI_ICON7));
  88.     mImageList->Add(pApp->LoadIcon(IDI_ICON8));
  89.     mImageList->Add(pApp->LoadIcon(IDI_ICON9));
  90.  
  91.     return TRUE;
  92. }
  93.  
  94. /*************************************************************************
  95. **************************************************************************
  96. **                                                                        **
  97. **            Name:         CreateFlatToolBar                                **
  98. **                                                                        **
  99. **            Parameters:  None                                           **
  100. **                                                                        **
  101. **            Description: Creates the Toolbar using the CImageList        **
  102. **                                                                        **
  103. **                                                                        **
  104. **************************************************************************
  105. **************************************************************************/
  106. void ToolBarDlg::CreateToolBar()
  107. {
  108.  
  109.     // Setup the Image list
  110.     SetupImages(&m_pImageList);
  111.  
  112.     TBBUTTON tb;
  113.  
  114.     // Create the Toolbar
  115.     m_ToolBar.Create(WS_CHILD|WS_VISIBLE|WS_BORDER | CCS_NORESIZE, CRect(0,0,400,100), this, 0);
  116.  
  117.     // Setup the image list to be used for the toolbar
  118.     m_ToolBar.SetImageList(&m_pImageList);
  119.  
  120.     // Toolbar Button #1
  121.     tb.iBitmap = 0;
  122.     tb.iString = NULL;
  123.     tb.fsState = TBSTATE_ENABLED;
  124.     tb.fsStyle = TBSTYLE_BUTTON;
  125.     tb.idCommand = ID_PRINTER;
  126.     m_ToolBar.AddButtons(1, &tb);
  127.  
  128.     // Toolbar Button #2
  129.     tb.iBitmap = 1;
  130.     tb.idCommand = ID_NEW;
  131.     m_ToolBar.AddButtons(1, &tb);
  132.  
  133.     // Toolbar Button #3
  134.     tb.iBitmap = 2;
  135.     tb.idCommand = ID_SAVE;
  136.     m_ToolBar.AddButtons(1, &tb);
  137.  
  138.     // Toolbar Button #4
  139.     tb.iBitmap = 3;
  140.     tb.idCommand = ID_ERASE;
  141.     tb.iString = NULL;
  142.     m_ToolBar.AddButtons(1, &tb);
  143.  
  144.     // Toolbar Button #5
  145.     tb.iBitmap = 4;
  146.     tb.idCommand = ID_RED;
  147.     m_ToolBar.AddButtons(1, &tb);
  148.  
  149.     // Toolbar Button #6
  150.     tb.iBitmap = 5;
  151.     tb.idCommand = ID_BLUE;
  152.     m_ToolBar.AddButtons(1, &tb);
  153.  
  154.     // Toolbar Button #7
  155.     tb.iBitmap = 6;
  156.     tb.idCommand = ID_YELLOW;
  157.     m_ToolBar.AddButtons(1, &tb);
  158.  
  159.     // Toolbar Button #8
  160.     tb.iBitmap = 7;
  161.     tb.idCommand = ID_PURPLE;
  162.     m_ToolBar.AddButtons(1, &tb);
  163.  
  164.     // Toolbar Button #9
  165.     tb.iBitmap = 8;
  166.     tb.idCommand = ID_WHITE;
  167.     m_ToolBar.AddButtons(1, &tb);
  168.  
  169.  
  170. }
  171.  
  172.  
  173. /*************************************************************************
  174. **************************************************************************
  175. **                                                                        **
  176. **            Name:         OnDumpit                                        **
  177. **                                                                        **
  178. **            Parameters:  None                                                 **
  179. **                                                                        **
  180. **            Description: Signals the Print Routine in HTBasic            **
  181. **                                                                        **
  182. **                                                                        **
  183. **************************************************************************
  184. **************************************************************************/
  185. void ToolBarDlg::OnDumpit()
  186. {
  187.     Signal(1);
  188. }
  189.  
  190.  
  191. /*************************************************************************
  192. **************************************************************************
  193. **                                                                        **
  194. **            Name:         OnSavefile                                        **
  195. **                                                                        **
  196. **            Parameters:  None                                                 **
  197. **                                                                        **
  198. **            Description: Signals the SaveAs Routine in HTBasic            **
  199. **                                                                        **
  200. **                                                                        **
  201. **************************************************************************
  202. **************************************************************************/
  203. void ToolBarDlg::OnSavefile()
  204. {
  205.     Signal(3);    
  206. }
  207.  
  208.  
  209. /*************************************************************************
  210. **************************************************************************
  211. **                                                                        **
  212. **            Name:         OnNewpad                                        **
  213. **                                                                        **
  214. **            Parameters:  None                                                 **
  215. **                                                                        **
  216. **            Description: Signals the New Routine in HTBasic                **
  217. **                                                                        **
  218. **                                                                        **
  219. **************************************************************************
  220. **************************************************************************/
  221. void ToolBarDlg::OnNewpad()
  222. {
  223.     Signal(2);    
  224. }
  225.  
  226.  
  227. /*************************************************************************
  228. **************************************************************************
  229. **                                                                        **
  230. **            Name:         OnErase                                        **
  231. **                                                                        **
  232. **            Parameters:  None                                                 **
  233. **                                                                        **
  234. **            Description: Signals the Erase Routine in HTBasic            **
  235. **                                                                        **
  236. **                                                                        **
  237. **************************************************************************
  238. **************************************************************************/
  239. void ToolBarDlg::OnErase()
  240. {
  241.     Signal(4);
  242. }
  243.  
  244.  
  245. /*************************************************************************
  246. **************************************************************************
  247. **                                                                        **
  248. **            Name: OnRed                                                    **
  249. **                                                                        **
  250. **            Parameters: None                                                 **
  251. **                                                                        **
  252. **            Description: Signals the Color Red Routine in HTBasic        **
  253. **                                                                        **
  254. **                                                                        **
  255. **************************************************************************
  256. **************************************************************************/
  257. void ToolBarDlg::OnRed()
  258. {
  259.     Signal(5);
  260. }
  261.  
  262.  
  263. /*************************************************************************
  264. **************************************************************************
  265. **                                                                        **
  266. **            Name: OnBlue                                                **
  267. **                                                                        **
  268. **            Parameters: None                                                 **
  269. **                                                                        **
  270. **            Description: Signals the Color Blue Routine in HTBasic        **
  271. **                                                                        **
  272. **                                                                        **
  273. **************************************************************************
  274. **************************************************************************/
  275. void ToolBarDlg::OnBlue()
  276. {
  277.     Signal(6);
  278. }
  279.  
  280.  
  281. /*************************************************************************
  282. **************************************************************************
  283. **                                                                        **
  284. **            Name: OnYellow                                                **
  285. **                                                                        **
  286. **            Parameters: None                                                 **
  287. **                                                                        **
  288. **            Description: Signals the Yellow Routine in HTBasic            **
  289. **                                                                        **
  290. **                                                                        **
  291. **************************************************************************
  292. **************************************************************************/
  293. void ToolBarDlg::OnYellow()
  294. {
  295.     Signal(7);
  296. }
  297.  
  298.  
  299. /*************************************************************************
  300. **************************************************************************
  301. **                                                                        **
  302. **            Name: OnPurple                                                **
  303. **                                                                        **
  304. **            Parameters: None                                                 **
  305. **                                                                        **
  306. **            Description: Signals the Purple Routine in HTBasic            **
  307. **                                                                        **
  308. **                                                                        **
  309. **************************************************************************
  310. **************************************************************************/
  311. void ToolBarDlg::OnPurple()
  312. {
  313.     Signal(8);
  314. }
  315.  
  316.  
  317. /*************************************************************************
  318. **************************************************************************
  319. **                                                                        **
  320. **            Name: OnWhite                                                **
  321. **                                                                        **
  322. **            Parameters: None                                                 **
  323. **                                                                        **
  324. **            Description: Signals the White Routine in HTBasic            **
  325. **                                                                        **
  326. **                                                                        **
  327. **************************************************************************
  328. **************************************************************************/
  329. void ToolBarDlg::OnWhite()
  330. {
  331.     Signal(9);
  332. }
  333.